package com.wzk.travelspringboot.config;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: WangZiKang
 * @Date: 2025/1/6 22:21
 */
@Configuration
public class JsonMapperConfig {
    @Bean
    public ObjectMapper objectMapper(){
        ObjectMapper objectMapper = new ObjectMapper();
        //配置保留 null 值
        objectMapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, true);
        // 注册 JavaTimeModule，启用对 Java 8 日期时间类型的支持
        objectMapper.registerModule(new JavaTimeModule());
        return objectMapper;
    }


}
